<?php
class MY_Form_validation extends CI_Form_validation {

    public function __construct()
    {
        parent::__construct();
    }
    
    function valid_date($str,$format= 'dd/mm/yyyy')
	 {
	        switch($format)
	        {
	
	            case 'yyyy/mm/dd':
	                if(preg_match("/^(19\d\d|2\d\d\d)[\/|-](0?[1-9]|1[012])[\/|-](0?[1-9]|[12][0-9]|3[01])$/", $str,$match) && checkdate($match[2],$match[3],$match[1]))
	                {
	                    return TRUE;
	                }
	            break;
	            case 'mm/dd/yyyy':
	                if(preg_match("/^(0?[1-9]|1[012])[\/|-](0?[1-9]|[12][0-9]|3[01])[\/|-](19\d\d|2\d\d\d)$/", $str,$match) && checkdate($match[1],$match[2],$match[3]))
	                {
	                    return TRUE;
	                }
	            break;
	            default: // 'dd/mm/yyyy'
	                if(preg_match("/^(0?[1-9]|[12][0-9]|3[01])[\/|-](0?[1-9]|1[012])[\/|-](19\d\d|2\d\d\d)$/", $str,$match) && checkdate($match[2],$match[1],$match[3]))
	                {
	                return TRUE;
	                }
	            break;
	
	        }
	        return FALSE;
	 } 
    
	public function valid_dates($date) {
        if (!empty($date))
        {
            if (preg_match("/^(\d{1,2})[- \/.](\d{1,2})[- \/.](\d{4})$/", $date, $values))     // Is a date format (dd mm yyyy)
            {
                if (checkdate($values[2], $values[1], $values[3]))    // Date really exists
                {
                    return TRUE;
                }
            }
        }
        return FALSE;
    }
}
 

/* End of file: MY_Form_validation.php */
/* Location: application/core/MY_Form_validation.php */  